<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Error_exception {

    function __construct() {
        $this->CI = & get_instance();
        $this->CI->load->language('form_validation');
        $this->lang = & $this->CI->lang;
    }

    function get_error($error = '', $start_tag = '', $end_tag = '') {
        $str = '';
        if (!empty($error)) {
            $tmparr = explode('||', $error);
            foreach ($tmparr as $element) {
                $arr = explode('#', $element);
                if (count($arr) == 1) {
                    $str .= $start_tag . $this->lang->line($arr[0]) . $end_tag;
                } elseif (count($arr) == 2) {
                    $str .= $start_tag . sprintf($this->lang->line($arr[0]), $this->lang->line($arr[1])) . $end_tag;
                } elseif (count($arr) == 3) {
                    $str .= $start_tag . sprintf($this->lang->line($arr[0]), $this->lang->line($arr[1]), $this->lang->line($arr[2])) . $end_tag;
                }
            }
        }
        return $str;
    }

}
